package com.wan.core.strategy;

import com.wan.core.strategy.selector.Selector;

import java.util.Collection;

public abstract class StrategySelectorCreator<K, T, S extends Selector<K, T>> {

    protected S selector;

    public final S init(Collection<T> objs) {
        if (selector != null) {
            return selector;
        }
        selector = newSelector(objs);
        return selector;
    }

    protected abstract S newSelector(Collection<T> objs);

    public final S getSelector() {
        return selector;
    }
}
